package a6;

public class FibsAndPrimes 
{

	public static void main(String[] args) 
	{
		int max= 10000;
		int [] fib = new int[1000];	// is there a way to limit array length to only what you assign?
		for ( int i=1, n1=0 , n2=1, n3 = 0 ; n3<max ; i++, n1=n2, n2=n3, n3=n2+n1 )  //get the fibs
		{
			fib[i] =n3;
		}
		
		int [] prime = new int[3000];
		boolean check;
		for(int i=2 ,j=1 ; i<max ;i++  )			//get the primes
		{
			check=isPrime(i);
			if (check)
				{
					prime[j] = i;
					System.out.println(prime[j]);
					j++;
				}
		}
		
		int [] both =new int[10000];  
		for (int i=1, k=1; fib[i]<max; i++ )		//run through fibs
		{
			for(int j=1; prime[j]<max ; j++ )		//run through primes
			{
				if (prime[j] == fib[i] )		//see if they match
				{
					both[k]= prime[j];
					System.out.println(k + " : " + fib[i]);
					k++;
				}
			}
		}	
	}
	
	private static boolean isPrime( int n)		//prime check
	{
		for(int m=2; m<=Math.sqrt(n) ; m++ )		
		{
			if(0==n%m )	
				return false;
		}
		return true;
		
	}
}

